﻿using System.Windows;
using GBlason.ViewModel.CoatOfArm;

namespace GBlason.Control.Aggregate
{
    /// <summary>
    /// The component used to display and GRAPHICALLY update the CoA.
    /// </summary>
    public partial class CoatOfArmsViewer
    {
        public CoatOfArmsViewer()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty CoatOfArmsProperty =
            DependencyProperty.Register("CoatOfArms", typeof(CoatOfArmViewModel), typeof(CoatOfArmsViewer),
            new PropertyMetadata(default(CoatOfArmViewModel)));

        public CoatOfArmViewModel CoatOfArms
        {
            get { return (CoatOfArmViewModel)GetValue(CoatOfArmsProperty); }
            set
            {
                SetValue(CoatOfArmsProperty, value);
            }
        }

        /// <summary>
        /// Update the size of the display available area. We have to use those data to update the FitToScreen ratio calculations.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.SizeChangedEventArgs"/> instance containing the event data.</param>
        private void GlobalScrollViewerSizeChanged(object sender, SizeChangedEventArgs e)
        {
            CoatOfArms.ParentFile.DisplayCoAAreaSize = e.NewSize;
        }
    }
}
